\(\int x \cot ^2(a+b x) \, dx\) [8]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [B] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 10, antiderivative size = 31 \[ \int x \cot ^2(a+b x) \, dx=-\frac {x^2}{2}-\frac {x \cot (a+b x)}{b}+\frac {\log (\sin (a+b x))}{b^2} \]

[Out]

-1/2*x^2-x*cot(b*x+a)/b+ln(sin(b*x+a))/b^2

Rubi [A] (verified)

Time = 0.03 (sec) , antiderivative size = 31, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.300, Rules used = {3801, 3556, 30} \[ \int x \cot ^2(a+b x) \, dx=\frac {\log (\sin (a+b x))}{b^2}-\frac {x \cot (a+b x)}{b}-\frac {x^2}{2} \]

[In]

Int[x*Cot[a + b*x]^2,x]

[Out]

-1/2*x^2 - (x*Cot[a + b*x])/b + Log[Sin[a + b*x]]/b^2

Rule 30

Int[(x_)^(m_.), x_Symbol] :> Simp[x^(m + 1)/(m + 1), x] /; FreeQ[m, x] && NeQ[m, -1]

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3801

Int[((c_.) + (d_.)*(x_))^(m_.)*((b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[b*(c + d*x)^m*((b*Tan[e
 + f*x])^(n - 1)/(f*(n - 1))), x] + (-Dist[b*d*(m/(f*(n - 1))), Int[(c + d*x)^(m - 1)*(b*Tan[e + f*x])^(n - 1)
, x], x] - Dist[b^2, Int[(c + d*x)^m*(b*Tan[e + f*x])^(n - 2), x], x]) /; FreeQ[{b, c, d, e, f}, x] && GtQ[n,
1] && GtQ[m, 0]

Rubi steps \begin{align*} \text {integral}& = -\frac {x \cot (a+b x)}{b}+\frac {\int \cot (a+b x) \, dx}{b}-\int x \, dx \\ & = -\frac {x^2}{2}-\frac {x \cot (a+b x)}{b}+\frac {\log (\sin (a+b x))}{b^2} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.25 (sec) , antiderivative size = 44, normalized size of antiderivative = 1.42 \[ \int x \cot ^2(a+b x) \, dx=-\frac {x^2}{2}-\frac {x \cot (a)}{b}+\frac {\log (\sin (a+b x))}{b^2}+\frac {x \csc (a) \csc (a+b x) \sin (b x)}{b} \]

[In]

Integrate[x*Cot[a + b*x]^2,x]

[Out]

-1/2*x^2 - (x*Cot[a])/b + Log[Sin[a + b*x]]/b^2 + (x*Csc[a]*Csc[a + b*x]*Sin[b*x])/b

Maple [A] (verified)

Time = 0.24 (sec) , antiderivative size = 40, normalized size of antiderivative = 1.29

method result size
default \(-\frac {x^{2}}{2}+\frac {-\left (b x +a \right ) \cot \left (b x +a \right )+\ln \left (\sin \left (b x +a \right )\right )+a \cot \left (b x +a \right )}{b^{2}}\) \(40\)
parallelrisch \(\frac {-x^{2} b^{2}-2 b x \cot \left (b x +a \right )+2 \ln \left (\tan \left (b x +a \right )\right )-\ln \left (\sec \left (b x +a \right )^{2}\right )}{2 b^{2}}\) \(45\)
norman \(\frac {-\frac {x}{b}-\frac {\tan \left (b x +a \right ) x^{2}}{2}}{\tan \left (b x +a \right )}+\frac {\ln \left (\tan \left (b x +a \right )\right )}{b^{2}}-\frac {\ln \left (1+\tan \left (b x +a \right )^{2}\right )}{2 b^{2}}\) \(56\)
risch \(-\frac {x^{2}}{2}-\frac {2 i x}{b}-\frac {2 i a}{b^{2}}-\frac {2 i x}{b \left ({\mathrm e}^{2 i \left (b x +a \right )}-1\right )}+\frac {\ln \left ({\mathrm e}^{2 i \left (b x +a \right )}-1\right )}{b^{2}}\) \(57\)

[In]

int(x*cot(b*x+a)^2,x,method=_RETURNVERBOSE)

[Out]

-1/2*x^2+1/b^2*(-(b*x+a)*cot(b*x+a)+ln(sin(b*x+a))+a*cot(b*x+a))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 75 vs. \(2 (29) = 58\).

Time = 0.25 (sec) , antiderivative size = 75, normalized size of antiderivative = 2.42 \[ \int x \cot ^2(a+b x) \, dx=-\frac {b^{2} x^{2} \sin \left (2 \, b x + 2 \, a\right ) + 2 \, b x \cos \left (2 \, b x + 2 \, a\right ) + 2 \, b x - \log \left (-\frac {1}{2} \, \cos \left (2 \, b x + 2 \, a\right ) + \frac {1}{2}\right ) \sin \left (2 \, b x + 2 \, a\right )}{2 \, b^{2} \sin \left (2 \, b x + 2 \, a\right )} \]

[In]

integrate(x*cot(b*x+a)^2,x, algorithm="fricas")

[Out]

-1/2*(b^2*x^2*sin(2*b*x + 2*a) + 2*b*x*cos(2*b*x + 2*a) + 2*b*x - log(-1/2*cos(2*b*x + 2*a) + 1/2)*sin(2*b*x +
 2*a))/(b^2*sin(2*b*x + 2*a))

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 65 vs. \(2 (26) = 52\).

Time = 0.21 (sec) , antiderivative size = 65, normalized size of antiderivative = 2.10 \[ \int x \cot ^2(a+b x) \, dx=\begin {cases} \tilde {\infty } x^{2} & \text {for}\: a = 0 \wedge b = 0 \\\frac {x^{2} \cot ^{2}{\left (a \right )}}{2} & \text {for}\: b = 0 \\\tilde {\infty } x^{2} & \text {for}\: a = - b x \\- \frac {x^{2}}{2} - \frac {x}{b \tan {\left (a + b x \right )}} - \frac {\log {\left (\tan ^{2}{\left (a + b x \right )} + 1 \right )}}{2 b^{2}} + \frac {\log {\left (\tan {\left (a + b x \right )} \right )}}{b^{2}} & \text {otherwise} \end {cases} \]

[In]

integrate(x*cot(b*x+a)**2,x)

[Out]

Piecewise((zoo*x**2, Eq(a, 0) & Eq(b, 0)), (x**2*cot(a)**2/2, Eq(b, 0)), (zoo*x**2, Eq(a, -b*x)), (-x**2/2 - x
/(b*tan(a + b*x)) - log(tan(a + b*x)**2 + 1)/(2*b**2) + log(tan(a + b*x))/b**2, True))

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 269 vs. \(2 (29) = 58\).

Time = 0.36 (sec) , antiderivative size = 269, normalized size of antiderivative = 8.68 \[ \int x \cot ^2(a+b x) \, dx=\frac {2 \, {\left (b x + a + \frac {1}{\tan \left (b x + a\right )}\right )} a - \frac {{\left (b x + a\right )}^{2} \cos \left (2 \, b x + 2 \, a\right )^{2} + {\left (b x + a\right )}^{2} \sin \left (2 \, b x + 2 \, a\right )^{2} - 2 \, {\left (b x + a\right )}^{2} \cos \left (2 \, b x + 2 \, a\right ) + {\left (b x + a\right )}^{2} - {\left (\cos \left (2 \, b x + 2 \, a\right )^{2} + \sin \left (2 \, b x + 2 \, a\right )^{2} - 2 \, \cos \left (2 \, b x + 2 \, a\right ) + 1\right )} \log \left (\cos \left (b x + a\right )^{2} + \sin \left (b x + a\right )^{2} + 2 \, \cos \left (b x + a\right ) + 1\right ) - {\left (\cos \left (2 \, b x + 2 \, a\right )^{2} + \sin \left (2 \, b x + 2 \, a\right )^{2} - 2 \, \cos \left (2 \, b x + 2 \, a\right ) + 1\right )} \log \left (\cos \left (b x + a\right )^{2} + \sin \left (b x + a\right )^{2} - 2 \, \cos \left (b x + a\right ) + 1\right ) + 4 \, {\left (b x + a\right )} \sin \left (2 \, b x + 2 \, a\right )}{\cos \left (2 \, b x + 2 \, a\right )^{2} + \sin \left (2 \, b x + 2 \, a\right )^{2} - 2 \, \cos \left (2 \, b x + 2 \, a\right ) + 1}}{2 \, b^{2}} \]

[In]

integrate(x*cot(b*x+a)^2,x, algorithm="maxima")

[Out]

1/2*(2*(b*x + a + 1/tan(b*x + a))*a - ((b*x + a)^2*cos(2*b*x + 2*a)^2 + (b*x + a)^2*sin(2*b*x + 2*a)^2 - 2*(b*
x + a)^2*cos(2*b*x + 2*a) + (b*x + a)^2 - (cos(2*b*x + 2*a)^2 + sin(2*b*x + 2*a)^2 - 2*cos(2*b*x + 2*a) + 1)*l
og(cos(b*x + a)^2 + sin(b*x + a)^2 + 2*cos(b*x + a) + 1) - (cos(2*b*x + 2*a)^2 + sin(2*b*x + 2*a)^2 - 2*cos(2*
b*x + 2*a) + 1)*log(cos(b*x + a)^2 + sin(b*x + a)^2 - 2*cos(b*x + a) + 1) + 4*(b*x + a)*sin(2*b*x + 2*a))/(cos
(2*b*x + 2*a)^2 + sin(2*b*x + 2*a)^2 - 2*cos(2*b*x + 2*a) + 1))/b^2

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 1026 vs. \(2 (29) = 58\).

Time = 0.73 (sec) , antiderivative size = 1026, normalized size of antiderivative = 33.10 \[ \int x \cot ^2(a+b x) \, dx=\text {Too large to display} \]

[In]

integrate(x*cot(b*x+a)^2,x, algorithm="giac")

[Out]

-1/2*(b^2*x^2*tan(1/2*b*x)^2*tan(1/2*a) + b^2*x^2*tan(1/2*b*x)*tan(1/2*a)^2 - b*x*tan(1/2*b*x)^2*tan(1/2*a)^2
- b^2*x^2*tan(1/2*b*x) - b^2*x^2*tan(1/2*a) + b*x*tan(1/2*b*x)^2 + 4*b*x*tan(1/2*b*x)*tan(1/2*a) - log(16*(tan
(1/2*b*x)^4*tan(1/2*a)^2 + 2*tan(1/2*b*x)^3*tan(1/2*a)^3 + tan(1/2*b*x)^2*tan(1/2*a)^4 - 2*tan(1/2*b*x)^3*tan(
1/2*a) - 4*tan(1/2*b*x)^2*tan(1/2*a)^2 - 2*tan(1/2*b*x)*tan(1/2*a)^3 + tan(1/2*b*x)^2 + 2*tan(1/2*b*x)*tan(1/2
*a) + tan(1/2*a)^2)/(tan(1/2*b*x)^4*tan(1/2*a)^4 + 2*tan(1/2*b*x)^4*tan(1/2*a)^2 + 2*tan(1/2*b*x)^2*tan(1/2*a)
^4 + tan(1/2*b*x)^4 + 4*tan(1/2*b*x)^2*tan(1/2*a)^2 + tan(1/2*a)^4 + 2*tan(1/2*b*x)^2 + 2*tan(1/2*a)^2 + 1))*t
an(1/2*b*x)^2*tan(1/2*a) + b*x*tan(1/2*a)^2 - log(16*(tan(1/2*b*x)^4*tan(1/2*a)^2 + 2*tan(1/2*b*x)^3*tan(1/2*a
)^3 + tan(1/2*b*x)^2*tan(1/2*a)^4 - 2*tan(1/2*b*x)^3*tan(1/2*a) - 4*tan(1/2*b*x)^2*tan(1/2*a)^2 - 2*tan(1/2*b*
x)*tan(1/2*a)^3 + tan(1/2*b*x)^2 + 2*tan(1/2*b*x)*tan(1/2*a) + tan(1/2*a)^2)/(tan(1/2*b*x)^4*tan(1/2*a)^4 + 2*
tan(1/2*b*x)^4*tan(1/2*a)^2 + 2*tan(1/2*b*x)^2*tan(1/2*a)^4 + tan(1/2*b*x)^4 + 4*tan(1/2*b*x)^2*tan(1/2*a)^2 +
 tan(1/2*a)^4 + 2*tan(1/2*b*x)^2 + 2*tan(1/2*a)^2 + 1))*tan(1/2*b*x)*tan(1/2*a)^2 - b*x + log(16*(tan(1/2*b*x)
^4*tan(1/2*a)^2 + 2*tan(1/2*b*x)^3*tan(1/2*a)^3 + tan(1/2*b*x)^2*tan(1/2*a)^4 - 2*tan(1/2*b*x)^3*tan(1/2*a) -
4*tan(1/2*b*x)^2*tan(1/2*a)^2 - 2*tan(1/2*b*x)*tan(1/2*a)^3 + tan(1/2*b*x)^2 + 2*tan(1/2*b*x)*tan(1/2*a) + tan
(1/2*a)^2)/(tan(1/2*b*x)^4*tan(1/2*a)^4 + 2*tan(1/2*b*x)^4*tan(1/2*a)^2 + 2*tan(1/2*b*x)^2*tan(1/2*a)^4 + tan(
1/2*b*x)^4 + 4*tan(1/2*b*x)^2*tan(1/2*a)^2 + tan(1/2*a)^4 + 2*tan(1/2*b*x)^2 + 2*tan(1/2*a)^2 + 1))*tan(1/2*b*
x) + log(16*(tan(1/2*b*x)^4*tan(1/2*a)^2 + 2*tan(1/2*b*x)^3*tan(1/2*a)^3 + tan(1/2*b*x)^2*tan(1/2*a)^4 - 2*tan
(1/2*b*x)^3*tan(1/2*a) - 4*tan(1/2*b*x)^2*tan(1/2*a)^2 - 2*tan(1/2*b*x)*tan(1/2*a)^3 + tan(1/2*b*x)^2 + 2*tan(
1/2*b*x)*tan(1/2*a) + tan(1/2*a)^2)/(tan(1/2*b*x)^4*tan(1/2*a)^4 + 2*tan(1/2*b*x)^4*tan(1/2*a)^2 + 2*tan(1/2*b
*x)^2*tan(1/2*a)^4 + tan(1/2*b*x)^4 + 4*tan(1/2*b*x)^2*tan(1/2*a)^2 + tan(1/2*a)^4 + 2*tan(1/2*b*x)^2 + 2*tan(
1/2*a)^2 + 1))*tan(1/2*a))/(b^2*tan(1/2*b*x)^2*tan(1/2*a) + b^2*tan(1/2*b*x)*tan(1/2*a)^2 - b^2*tan(1/2*b*x) -
 b^2*tan(1/2*a))

Mupad [B] (verification not implemented)

Time = 12.09 (sec) , antiderivative size = 54, normalized size of antiderivative = 1.74 \[ \int x \cot ^2(a+b x) \, dx=\frac {\ln \left ({\mathrm {e}}^{a\,2{}\mathrm {i}}\,{\mathrm {e}}^{b\,x\,2{}\mathrm {i}}-1\right )}{b^2}-\frac {x\,2{}\mathrm {i}}{b}-\frac {x^2}{2}-\frac {x\,2{}\mathrm {i}}{b\,\left ({\mathrm {e}}^{a\,2{}\mathrm {i}+b\,x\,2{}\mathrm {i}}-1\right )} \]

[In]

int(x*cot(a + b*x)^2,x)

[Out]

log(exp(a*2i)*exp(b*x*2i) - 1)/b^2 - (x*2i)/b - x^2/2 - (x*2i)/(b*(exp(a*2i + b*x*2i) - 1))